<!DOCTYPE html>

<html>
	<head>

		  <meta charset="utf-8">
		  <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
		  <meta name="apple-mobile-web-app-capable" content="yes">
		  <meta name="apple-mobile-web-app-status-bar-style" content="black">
		  <title></title>
		  
		  <link rel="stylesheet" href="../css/jquery.mobile-1.3.1.min.css">
		 
		  <!-- Extra Codiqa features -->
			  <link rel="stylesheet" href="codiqa.ext.css">
			  <link rel="stylesheet" href="file:///android_asset/css/in.css">
		  
		  <!-- jQuery and jQuery Mobile -->
			  <script src="https://d10ajoocuyu32n.cloudfront.net/jquery-1.9.1.min.js"></script>
			  <script src="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
			  <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
		  <!-- Extra Codiqa features -->
		      <script src="https://d10ajoocuyu32n.cloudfront.net/codiqa.ext.js"></script>
			  <script src="file:///android_asset/js/login.js"></script>		   
	</head>
<body style="background:#ffffff !important;">
	<!-- Home -->
	<div data-role="page" id="page1" data-theme="b">
           <!-- <div class="ui-header ui-bar-b" align="center" data-theme="b" data-role="header" role="banner">
				<div class="ui-title" role="heading" aria-level="1">
					<font size="3">Sign In</font>
				</div>
            </div>-->
			<div > 
				<center><img src="../images/forerunner_logo_final_header_480x200.png"  height="115" width="316" ></center>
			</div>
			<!-- Header -->
            <div data-role="content" >
              <form action="" method="POST" id='loginForm' name='loginForm'>
					<div id="emailDiv" style="margin:15px 0px 0px 0px">
						<input type="email" id="email" name="email" placeholder="email address" />
					</div>
					
					<div id="pwdDiv">
						<input type="password" id="pwd" name="pwd" placeholder="password" />
					</div> 
					
					<div>
						<center><input type="checkbox" style="margin:1px 0 0 -21px" height="45" width="100" id="check1" value="0" name="check1" onclick=""/>
						 <div style="margin:0 0 0 -136px;font-family:Lucida Sans Unicode; font-size:18px">Remember Me</div> </center>
					</div>		</br></br>		
					
					<div> 
						<center> <a href="#" align="center"> <img src="../images/signin.png" onclick="userLogin()"></a></center>
					</div></br></br></br>
					
					<div> 
						<center><style="font-family:Lucida Sans Unicode;" align="center"> Need an Account? </center>
						<center> <a href="#" align="center"> <img src="../images/create_account.png" onclick="goCreateAccount()"></a></center>
					</div> 
			    </form>
			</div>
	</div>
	<!--<div style="background-image: url(../images/topbar.png); bottom:0;text-align:center;margin:0px 0px 0px 0px;" id="sample" class="ui-footer-fixed " > 
				<div style="margin:8px 0px -7px 17px;">
					<img  style="margin:0px -1px 13px -17px;" class="folder" src="../images/folder.png"  height="40" width="40">
					<img  style="margin:0px -1px 13px 19px;" class="folder" src="../images/settings.png" height="40" width="40">
					<img  style="margin:0px -1px 13px 19px;" class="" src="../images/home.png" height="40" width="40" onclick="home()">
					<img  style="margin:0px -1px 13px 19px;" class="folder" src="../images/boulder.png" height="40" width="40" onclick="boulder()">
					<img  style="margin:0px -1px 13px 19px;" class="folder" src="../images/route.png" height="40" width="40" onclick="route()">
				</div>
	</div>-->
	
</body>
</html>
	<script type="text/javascript" charset="utf-8" src="file:///android_asset/js/cordova.js"></script>
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
	<script>
	document.addEventListener("deviceready", updateRopeRoute, false);
	function updateRopeRoute(){
			if(window.localStorage.getItem("key")!=null){
				document.getElementById('email').value=window.localStorage.getItem("key");
				document.getElementById('pwd').value=window.localStorage.getItem("key1");
				document.getElementById('check1').checked=true;
			}
			if(window.localStorage["token"]!=''){
				window.localStorage["token"]='';
			}			
	}
	function userLogin(){
		var email=document.getElementById('email').value;
		var pwd=document.getElementById('pwd').value;
		if(pwd==""){
			navigator.notification.alert("Enter Password!"); return false}
		if(email==""){
			navigator.notification.alert("Enter Email!"); return false;}
			window.localStorage["url"]='http://192.237.186.169/forerunner';
		$.ajax({
				 url: window.localStorage["url"]+'/login?token=BicOjMGGCG/NmuPjmG4RiA==',
				 type: "POST",
			 	 dataType: "json",	
				 data:{userName:email,password:pwd},							 
			     success: function(msg){
						if(msg.status == "SUCCESS"){
							window.localStorage["token"]=msg.token;
							window.localStorage.setItem("key",email);
							window.localStorage.setItem("key1",pwd);
							window.localStorage["username1"]=email;
							if(document.getElementById('check1').checked==true){
								window.location='option.html';
							}else{
								window.localStorage.removeItem("key");
								window.localStorage.removeItem("key1");
								window.location='option.html';}					
					}else{
						navigator.notification.alert(msg.errorMessage);
					}
				 }			 
			});
	}
	function goCreateAccount(){
		window.location='create_account.html';
	}
	</script>